package com.shenhaofeng.app.loader.list.internal;

import android.os.Looper;

import java.util.concurrent.Executor;

import rx.Scheduler;
import rx.android.schedulers.AndroidSchedulers;
import rx.schedulers.Schedulers;


/**
 * Created by Administrator on 2016/9/30.
 */
public class LoadSchedulers {

    private Executor mExecutor;

    protected Looper mLooper;


    public LoadSchedulers() {
    }


    public LoadSchedulers(Executor mExecutor) {
        this.mExecutor = mExecutor;
    }


    public LoadSchedulers(Looper mLooper) {
        this.mLooper = mLooper;
    }


    public Scheduler getWorkScheduler() {
        if (mExecutor != null) {
            return Schedulers.from(mExecutor);
        } else if (mLooper != null) {
            return AndroidSchedulers.from(mLooper);
        } else {
            return Schedulers.newThread();
        }
    }


}
